package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {

    //是老用户 进一步查询订单表判断套餐 当天是否重复预约
    @Select("select count(1) from t_order where SETMEAL_ID =#{sid} and ORDERDATE =#{orderDate} and MEMBER_ID =#{id} ")
    int findOrderBySetmealIdAndOrderDateAndMemberId(@Param("sid") int sid, @Param("orderDate") String orderDate, @Param("id") Integer id);

    //移动端根据订单id查询订单信息
    @Select("SELECT tm.NAME AS member,ts.NAME AS setmeal,ORDERDATE AS orderDate ,ORDERTYPE AS orderType " +
            "FROM t_order tor , t_member tm ,t_setmeal ts " +
            "WHERE tor.MEMBER_ID = tm.id AND tor.SETMEAL_ID = ts.id " +
            "AND tor.id = #{id}")
    Map findOrderInfoByOrderId(@Param("id") int id);
}
